package com.boot.shiro.exception;

import com.boot.shiro.controller.ShiroController;
import org.apache.shiro.authc.LockedAccountException;
import org.apache.shiro.authz.AuthorizationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ShiroException {
    private static Logger LOGGER = LoggerFactory.getLogger(ShiroException.class) ;

    @ExceptionHandler(AuthorizationException.class)
    public String authorizationException (){
        return "抱歉您没有权限访问该内容!";
    }

    @ExceptionHandler(LockedAccountException.class)
    public String lockedAccountException (){
        return "账号已被锁定,请联系管理员!";
    }

    @ExceptionHandler(Exception.class)
    public String handleException(Exception e){
        LOGGER.error("Exception:", e);
        return "系统异常!";
    }

}